import { Button } from 'antd'

var data = [
    { country: 1, product: 'Product A', sales: 1000 },
    { country: 2, product: 'Product B', sales: 1500 },
    { country: 0, product: 'Product A', sales: 800 },
    { country: 3, product: 'Product B', sales: 1200 }
];

const A04 = async () => {
    return ({
        url: 1000, // 临时获取数据
        classification: 'OLAP', // 页面类型选择
        initParameter: {    // 初始化函数
            // 总计显示 0:不显示总数 1:显示总数 2:显示小计和总计
            showRowTotals: 2,
            showColumnTotals: 2,
            fields: [
                { binding: 'date', header: '季度', format: '\"Q\"q yyyy' },
                { binding: 'date', header: '月份', format: 'MMMM' },
                { binding: 'country', header: '国家' },
                { binding: 'product', header: '城市' },
                { binding: 'discount', header: '折扣' },
                { binding: 'state', header: '状态' },
                { binding: 'downloads', header: '下载量', format: 'n0' },
                { binding: 'sales', header: '销售量', format: 'c2' },
                { binding: 'expenses', header: '成本费', format: 'c2' },
                { binding: 'num01', header: 'No.1', format: 'n2' },
                { binding: 'num02', header: 'No.2', format: 'n2' },
                { binding: 'num03', header: 'No.3', format: 'n2' },
                { binding: 'num04', header: 'No.4', format: 'n2' },
                { binding: 'num05', header: 'No.5', format: 'n2' },
                { binding: 'num06', header: 'No.6', format: 'n2' },
                // {
                //     dataType: 'String',
                //     header: '国家',
                //     binding: 'country',
                //     getValue: (e) => {
                //         const mapping = { 0: '中国', 1: '朝鲜', 2: '韩国', 3: '俄罗斯', 4: '日本' }
                //         return mapping[e.country]
                //     }
                // },
            ],
            rowFields: ['国家', '状态'],
            columnFields: ['城市'],
            valueFields: ['下载量', '销售量', '成本费'],
        },
        configuration: {// 基础配置
            // true     只读 Ps:常驻  
            isReadOnly: true,
            // 禁止排序操作 None:禁用 SingleColumn:单排 MultiColumn:多排 
            allowSorting: 'SingleColumn',
            // // false    禁止改变大小
            // allowResizing: false,
            // // 固定列方式 None:非固定,SingleColumn:单行固定,ColumnRange:多行固定
            // allowPinning: 'SingleColumn',
            // 表单选中 0:禁用 1:单元格 2:多单元格 3:单行 4:多行 5:多选行 MultiRange:列Ps:需关闭排序和拖动
            selectionMode: 5,
            // // 冻结行数
            // frozenRows: 2,
            // // 冻结列数
            // frozenColumns: 1,
            // 插件自带右键菜单
            customContextMenu: false,
            showDetailOnDoubleClick: false
        },

        optionsBtn: click => ([
            {
                key: '0',
                type: 'group',
                label: '数据更新',
                children: [
                    { key: '0-1', label: <Button type='link' onClick={() => click('onRefresh')}>刷新数据</Button> },
                    { key: '0-2', label: <Button type='link' onClick={() => click('onSearch')}>条件刷新</Button> },
                ]
            },
            {
                key: '1',
                type: 'group',
                label: '数据操作',
                children: [
                    { key: '1-1', label: <Button type='link' onClick={() => click('onRawData')}>原始数据</Button> },
                    { key: '1-2', label: <Button type='link' onClick={() => click('onConsole')}>数据中控</Button> },
                ],
            },
            {
                key: '2',
                type: 'group',
                label: '导出数据',
                children: [
                    { key: '2-1', label: <Button type='link' onClick={() => click('onSaveAct')}>导出选中数据</Button> },
                    { key: '2-2', label: <Button type='link' onClick={() => click('onSaveAll')}>导出全部数据</Button> },
                ],
            },
            {
                key: '3',
                type: 'group',
                label: '查看图例',
                children: [
                    { key: '3-1', label: <Button type='link' onClick={() => click('onChart')}>查看图例</Button> },
                ],
            },
        ]),

        gridConfig: {
            initParameter: {
                group: [],
                sort: [],
                groupPanel: true,
                filter: true,
                addSum: true,
                addIndex: true,
                topText: 'Ω',
                btmText: 'Ψ',
            },
            configuration: {
                allowSorting: 'MultiColumn',
                isReadOnly: true,
                selectionMode: 5,
                allowMerging: "Cells"
            },
            optionsBtn: click => ([
                {
                    key: '2',
                    type: 'group',
                    label: '导出数据',
                    children: [
                        { key: '2-1', label: <Button type='link' onClick={() => click('onSaveAct')}>导出选中数据</Button> },
                        { key: '2-2', label: <Button type='link' onClick={() => click('onSaveAll')}>导出全部数据</Button> },
                    ],
                },
            ]),
            columns: [
                {
                    dataIndex: 'uuid',
                    valueType: 'Hidden'
                },
                {
                    title: '国家',
                    dataIndex: 'country',
                    rules: true,
                    valueType: 'Select',
                    valueEnum: { 0: '中国', 1: '朝鲜', 2: '韩国', 3: '俄罗斯', 4: '日本' },
                    width: 240,
                    align: 'center',
                    // allowResizing: false,
                    // allowDragging: false,
                    // allowMerging: true
                },
                {
                    title: '地区',
                    dataIndex: 'product',
                    rules: true,
                    valueType: 'Select',
                    valueEnum: { 0: '北京', 1: '上海', 2: '深圳', 3: '重庆', 4: '四川' },
                    align: 'center',
                    // allowMerging: true
                },
                {
                    title: '时间',
                    dataIndex: 'date',
                    rules: true,
                    valueType: 'DatePicker',
                    format: 'yyyy/MM/dd',
                    align: 'center',
                },
                {
                    title: '状态',
                    dataIndex: 'state',
                    rules: true,
                    valueType: 'Select',
                    valueEnum: {
                        0: { text: '待领取...', status: 'default' },
                        1: { text: '解决中...', status: 'processing', disabled: true },
                        2: { text: '已解决!', status: 'success' },
                        3: { text: '警报中!', status: 'warning' },
                        4: { text: '无法解决!', status: 'error' },
                    },
                    align: 'center',
                    tooltip: '信息提示!',
                },
                {
                    title: '折扣',
                    dataIndex: 'discount',
                    valueType: 'InputNumber',
                    align: 'center',
                    format: 'p2',
                },
                {
                    title: '下载量',
                    dataIndex: 'downloads',
                    valueType: 'InputNumber',
                    align: 'center',
                    aggregate: 1,
                    format: 'n2',
                    aggTitle: '总计下载'
                },
                {
                    title: '销售量',
                    dataIndex: 'sales',
                    valueType: 'InputNumber',
                    align: 'center',
                    aggregate: 1,
                    format: 'c2',
                    aggTitle: '总计销售'
                },
                {
                    title: '成本费',
                    dataIndex: 'expenses',
                    valueType: 'InputNumber',
                    align: 'center',
                    aggregate: 1,
                    format: 'c2',
                    aggTitle: '成本合计'
                },
                {
                    title: 'No.1',
                    dataIndex: 'num01',
                    valueType: 'InputNumber',
                    align: 'center',
                    aggregate: 1,
                    format: 'n2',
                    aggTitle: '数值总和'
                },
                {
                    title: 'No.2',
                    dataIndex: 'num02',
                    valueType: 'InputNumber',
                    align: 'center',
                    aggregate: 2,
                    format: 'n2',
                    aggTitle: '非空行数'
                },
                {
                    title: 'No.3',
                    dataIndex: 'num03',
                    valueType: 'InputNumber',
                    align: 'center',
                    aggregate: 3,
                    format: 'n2',
                    aggTitle: '平均值'
                },
                {
                    title: 'No.4',
                    dataIndex: 'num04',
                    valueType: 'InputNumber',
                    align: 'center',
                    aggregate: 4,
                    format: 'n2',
                    aggTitle: '最大值'
                },
                {
                    title: 'No.5',
                    dataIndex: 'num05',
                    valueType: 'InputNumber',
                    align: 'center',
                    aggregate: 5,
                    format: 'n2',
                    aggTitle: '最小值'
                },
                {
                    title: 'No.6',
                    dataIndex: 'num06',
                    valueType: 'InputNumber',
                    align: 'center',
                    aggregate: 6,
                    format: 'n2',
                    aggTitle: '数值差值'
                },
            ],
        }

    })
}

export default A04